if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PreservationNoticeHistoryInsertNew]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].PreservationNoticeHistoryInsertNew
GO

CREATE PROCEDURE dbo.[PreservationNoticeHistoryInsertNew]
(
	@NewSiteID uniqueidentifier,
	@PreservationNoticeID  int,
	@EventType  varchar(50),
	@PreservationNoticeName varchar(100),
	@DateEmailMessageCreated datetime,
	@DateEmailMessageSent datetime,
	@DateAcknowledged datetime,
	@FromAddress varchar(500),
	@CustodianEmail varchar(500),
	@MessageSubject varchar(500), 
	@MessageBody text,
	@Identifier varchar(500),
	@InterviewDate datetime,
	@CustodianID int,
	@CustodianLastName varchar(200),
	@CustodianFirstName varchar(200),
	@HasAttachments bit,
	@PreservationNoticeHistoryID int OUTPUT
)
AS
SET NOCOUNT ON

SET @PreservationNoticeHistoryID = 0

INSERT INTO PreservationNoticeHistory
(
	SiteID,
	NewSiteID,
	PreservationNoticeID,
	EventType,
	PreservationNoticeName,
	DateEmailMessageCreated,
	DateEmailMessageSent,
	DateAcknowledged,
	FromAddress,
	CustodianEmail,
	MessageSubject, 
	MessageBody,
	Identifier,
	InterviewDate,
	CustodianID,
	CustodianLastName,
	CustodianFirstName,
	HasAttachments
) 
VALUES 
(
	@NewSiteID,
	@NewSiteID,
	@PreservationNoticeID,
	@EventType,
	@PreservationNoticeName,
	@DateEmailMessageCreated,
	@DateEmailMessageSent,
	@DateAcknowledged,
	@FromAddress,
	@CustodianEmail,
	@MessageSubject, 
	@MessageBody,
	@Identifier,
	@InterviewDate,
	@CustodianID,
	@CustodianLastName,
	@CustodianFirstName,
	@HasAttachments
)
SET @PreservationNoticeHistoryID = SCOPE_IDENTITY()
GO